using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerAnimationEventTrigger : MonoBehaviour
{
    private Player player;

    private void Awake()
    {
        player = transform.GetComponentInParent<Player>();
    }

    public void TriggerOnMovementStateAnimationEnter()
    {
        if (IsInAnimtionTransition())
            return;
        player.OnMovementStateAnimationEnterEvent();
    }
    
    public void TriggerOnMovementStateAnimationExit()
    {
        if (IsInAnimtionTransition())
            return;
        player.OnMovementStateAnimationExitEvent();
    }
    
    public void TriggerOnMovementStateAnimationTransition()
    {
        if (IsInAnimtionTransition())
            return;
        
        player.OnMovementStateAnimationTransitionEvent();
    }

    private bool IsInAnimtionTransition(int layerIndex = 0)
    {
        return player.Animator.IsInTransition(layerIndex);
    }
}
